#ifndef EXPERIMENT_CONFIG_HPP
#define EXPERIMENT_CONFIG_HPP

#include <NTL/GF2X.h>
NTL_CLIENT   

extern int scrubbing_selection_switch;                  // 1: staged scrubbing, 2: naive scrubbing
const static int use_error_log_before_ecc = 1;          // 1: use error log, 0: don't

// the parity check matrix for payload data
const static long N = 4376;                             // block length and the number of columns of the H matrix
const static long M = 281;                              // rownum, the number of rows of the H matrix
//const static long N = 8000;                             // block length and the number of columns of the H matrix
//const static long M = 3905;                              // rownum, the number of rows of the H matrix
const static long K = (N - M);                          // rownum of matrix G2

// the parity check matrix for metadata
const static long N2 = 3584;                            // block length of matrix H2
const static long M2 = 443;                             // rownum of matrix H2
const static long K2 = (N2 - M2);                       // rownum of matrix G2

extern double scrub_gap;
extern double scrub_gap_naive;
extern double total_time;
extern int trial_num;

#define TRIAL_NUM 1                    // the total number of trials
#define MAX_CELL_LEVEL 4               // the maximal levels which each cell has
#define MAX_ITER 32                    // iteration limit
#define BITS_PER_CELL 2                // number of bits which can be stored in a cell

#ifdef LDPC
#define NUM_CELL N/BITS_PER_CELL       // total number of cells used to store the codeword
#define CELL_PER_SEG 547               // number of cells in each segment
#endif

//#define VERBOSE true                   // switch this on will print out information during execution.
#define DEBUG false                    // switch this on to print out debugging information

// initial cell configurations
const static double resistance_thresholds[3] = {3.5, 4.5, 5.5};
const static double resistance_dev = 0.13;
const static double resistance_means[5] = {0.0, 3.0, 4.0, 5.0, 6.0};
const static double exponent_means[5] = {0.0, 0.005, 0.08, 0.09, 0.10};
const static double exponent_devs[5] = {0.0, 0.020, 0.032, 0.036, 0.040};

// configurations for BCH code
// length 4095, rate 0.935
const static long BCHm = 12;                                            /// GF(2^m)
const static long BCHn = (long) pow((double) 2, (double) BCHm) - 1;    // BCH block length
//const static long BCHt = 22;                                            // Error correction capability, note that t <= (BCHn -1)/2
const static long BCHt = 170;  // rate ~ 0.5
const static GF2X BCHpol = GF2X(12, 1) + GF2X(6, 1) + GF2X(4, 1) + GF2X(1, 1) + GF2X(0, 1);
//GF2X(4, 1) + GF2X(1, 1) + GF2X(0, 1);       // the realization of GF(2^m)

extern double fliprate;
extern long BCHk;                                       // message length for BCH code
extern GF2X BCHgenerator;                               // BCH generator polynomial

#ifdef BCH
#define NUM_CELL (BCHn + 1)/BITS_PER_CELL       // total number of cells used to store the codeword
#define CELL_PER_SEG 512               // number of cells in each segment
#endif



#endif //EXPERIMENT_CONFIG_HPP
